







#ifndef HI1711_H
#define HI1711_H

#include "hw/arm/boot.h"
#include "hw/cpu/a15mpcore.h"
#include "hw/sd/sdhci.h"
#include "exec/memory.h"
#include "cpu.h"
#include "hw/block/flash.h"
#include "exec/hwaddr.h"

#define TYPE_HI1711 "hi1711"
#define HI1711(obj) OBJECT_CHECK(HI1711_MachineState, (obj), TYPE_HI1711)

#define SCHED_CLOCK_FREQ 1000000
#define HI1711_NUM_CPUS 8
#define REDIST_REGION_CNT 8
#define HI1711_NUM_GPIO 5
#define HI1711_NUM_I2C 16
#define HI1711_NUM_IPMB 4
#define HI1711_NUM_UART 6
#define HI1711_NUM_GMAC 4
#define HI1711_NUM_WDG 6
#define HI1711_NUM_EFUSE 2
#define HI1711_LOADER_START 0x7480000
#define NUM_IRQS 256

void reset_hi1711_cpu(uint32_t cpu_index, uint32_t reset_address);

typedef struct HI1711_MachineState {
    /* < private > */
    DeviceState parent_obj;

    /* <public > */
    ARMCPU          cpu[HI1711_NUM_CPUS];
    MemoryRegion    ram;
    MemMapEntry     *memmap;
    const int       *irqmap;
    DeviceState     *gic;
    DeviceState     *gpio;
    DeviceState     *i2c[HI1711_NUM_I2C];
    DeviceState     *trng;
    DeviceState     *lp_subsys;
    DeviceState     *wdg[HI1711_NUM_WDG];
    DeviceState     *efuse[HI1711_NUM_EFUSE];
    DeviceState     *localbus;
	DeviceState     *ipmb[HI1711_NUM_IPMB];
} HI1711_MachineState;

enum {
    HI1711_DDR,

    HI1711_UART0,
    HI1711_UART1,
    HI1711_UART2,
    HI1711_UART3,
    HI1711_UART4,
    HI1711_UART5,

    HI1711_GIC_GICD,
    HI1711_GIC_GICR,

    HI1711_GPIO0,
    HI1711_GPIO1,
    HI1711_GPIO2,
    HI1711_GPIO3,
    HI1711_GPIO4,

    HI1711_MDIO0,

    HI1711_GMAC0,
    HI1711_GMAC1,
    HI1711_GMAC2,
    HI1711_GMAC3,

    HI1711_VIRTIO0,
    HI1711_VIRTIO1,
	HI1711_VIRTIO2,

    HI1711_I2C0,
    HI1711_I2C1,
    HI1711_I2C2,
    HI1711_I2C3,
    HI1711_I2C4,
    HI1711_I2C5,
    HI1711_I2C6,
    HI1711_I2C7,
    HI1711_I2C8,
    HI1711_I2C9,
    HI1711_I2C10,
    HI1711_I2C11,
    HI1711_I2C12,
    HI1711_I2C13,
    HI1711_I2C14,
    HI1711_I2C15,
	
	HI1711_IPMB0,
    HI1711_IPMB1,
    HI1711_IPMB2,
    HI1711_IPMB3,

    HI1711_TRNG,

    HI1711_LP_SUBSYS,

    HI1711_WDG0,
    HI1711_WDG1,
    HI1711_WDG2,
    HI1711_WDG3,
    HI1711_WDG4,
    HI1711_WDG5,

    HI1711_EFUSE0,
    HI1711_EFUSE1,

    HI1711_LOCALBUS,
};

#endif /* HI1711_H */
